<style type="text/css">
body,table,td,tr{
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:10px;
}

.level1{
	background-color:#BCBCBC;
}
.level2{
	background-color:#D1D1D1;
}
.level3{
	background-color:#E1E1E1;	
}
.level4{
	background-color:#F0F0F0;	
}
.level5{
	background-color:#FBFBFB;	
}

</style>
<?
include("lib/config.php");
/* 
	catatan:
	direktorat			level 1		2 digit
	koordiantor			level 2		2 digit
	cabang/divisi/biro	level 3		3 digit
	bagian				level 4		3 digit
	seksi				level 5		2 digit
	
	000000000000
	123456789123 mssql
	012345678900 php
	
*/

// get direktorat
?>
<form action="<?=$PHP_SELF?>" method="get">
<table>
 <tr>
  <td>Cari Posisi:</td>
  <td><input type="text" name="keyword" /></td>
  <td><input type="submit" value="Go" /></td>
 </tr>
</table>
</form>
<?
echo"<table border=0 cellpadding=0 cellspacing=1>
<tr>
 <td class='level1'><b>Direktorat</b></td>
 <td class='level2'><b>Koordinator</b></td>
 <td class='level3'><b>Biro/Divisi/Cabang/Unit Kerja</b></td>
 <td class='level4'><b>Bagian</b></td>
 <td class='level5'><b>Seksi</b></td>
</tr>
";
	$sql1 = mssql_query("select * from vleveldirektorat order by kode_so",$conn);
	while($row1 = mssql_fetch_array($sql1)){
		/*
		echo"
		<tr>
		 <td>direktorat</td>
		 <td colspan=4>&nbsp;</td>
		</tr>
		";
		*/
		echo"
		<tr>
		 <td class='level1'>&bull; $row1[uraian]</td>
		 <td class='level2'>&nbsp;</td>
		 <td class='level3'>&nbsp;</td>
		 <td class='level4'>&nbsp;</td>
		 <td class='level5'>&nbsp;</td>
		</tr>";
		// get koordinator
		$sql2 = mssql_query("select * from vlevelkoordinator where substring(kode_so,1,2)='".substr($row1[kode_so],0,2)."' order by kode_so",$conn);
		/*
		echo"
		<tr>
		 <td>&nbsp;</td>
		 <td colspan=4>koordinator</td>
		</tr>";
		*/
		while($row2 = mssql_fetch_array($sql2)){
			echo"
			<tr>
			 <td class='level1'>&nbsp;</td>
			 <td class='level2'>&bull; $row2[uraian]</td>
			 <td class='level3'>&nbsp;</td>
			 <td class='level4'>&nbsp;</td>
			 <td class='level5'>&nbsp;</td>
			</tr>";
		//	*/
			// get cabang/divisi/biro
			$sql3 = mssql_query("select * from vlevelcabang where substring(kode_so,1,2)='".substr($row1[kode_so],0,2)."' and substring(kode_so,3,2)='".substr($row2[kode_so],2,2)."' order by kode_so",$conn);
			//echo"<blockquote><br>";
			while($row3 = mssql_fetch_array($sql3)){
				//echo"<tr><td>&nbsp;</td><td>&nbsp;</td><td>cabang/biro/divisi</td></tr>";
				echo"
				<tr>
				 <td class='level1'>&nbsp;</td>
				 <td class='level2'>&nbsp;</td>
				 <td class='level3'>$row3[uraian]</td>
				 <td class='level4'>&nbsp;</td>
				 <td class='level5'>&nbsp;</td>
				</tr>";
				// get bagian
				$sql4 = mssql_query("select * from vlevelbagian where substring(kode_so,1,2)='".substr($row1[kode_so],0,2)."' and substring(kode_so,3,2)='".substr($row2[kode_so],2,2)."' and substring(kode_so,5,3)='".substr($row3[kode_so],4,3)."' order by kode_so",$conn);
				//echo"<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>bagian</td></tr>";
				while($row4 = mssql_fetch_array($sql4)){
					echo"
					<tr>
					 <td class='level1'>&nbsp;</td>
					 <td class='level2'>&nbsp;</td>
					 <td class='level3'>&nbsp;</td>
					 <td class='level4'>&bull; $row4[uraian]</td>
					 <td class='level5'>&nbsp;</td>
					</tr>";
					// get seksi
					$sql5 = mssql_query("select * from vlevelseksi where substring(kode_so,1,2)='".substr($row1[kode_so],0,2)."' and substring(kode_so,3,2)='".substr($row2[kode_so],2,2)."' and substring(kode_so,5,3)='".substr($row3[kode_so],4,3)."' and substring(kode_so,8,3)='".substr($row4[kode_so],7,3)."' order by kode_so",$conn);
					//echo"<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>seksi</td></tr>";
					while($row5 = mssql_fetch_array($sql5)){
						echo"
						<tr>
						 <td class='level1'>&nbsp;</td>
						 <td class='level2'>&nbsp;</td>
						 <td class='level3'>&nbsp;</td>
						 <td class='level4'>&nbsp;</td>
						 <td class='level5'>&bull; $row5[uraian]</td>
						</tr>";
					}
//					echo"</blockquote>";
				}
	//			echo"</blockquote>";
			}
		//	echo"</blockquote>";
		}
		//echo"</blockquote>";
	}
echo"</table>";	
?>